package javaCode;

/**
 * Created by lxy_920912 on 2017/2/20.
 */
public class LeetCode263 {
    public boolean isUgly(int num) {


        int[] primes = {2,3,5};
        if(num == 0){
            return false;
        }
        if(num == 1){
            return true;
        }
        boolean flag = true;
        while(flag){
            flag = false;
            for(int i = 0;i < 3;i++){
                if(num == primes[i]){

                    return true;
                }else if(num % primes[i] == 0 ){
                    num = num/primes[i];
                    flag = true;
                }
            }
        }
        return flag;
    }
}
